﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StuMngWx.Dals;
using StuMngWx.Entities;

namespace StuMngWx
{
    public partial class FormTeacherView : Form
    {
        public FormTeacherView()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            //DataTable dtSource = Dal4Teachers.SearchAllTeachers();
            //gvTeachers.DataSource = dtSource;

            List<Teacher> teachers = Dal4Teachers.SearchAllTeachersNew();
            gvTeachers.DataSource = teachers;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormAddTeacher formAddTeacher = new FormAddTeacher();
            formAddTeacher.ShowDialog();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            Teacher tcherSelected = gvTeachers.SelectedRows[0].DataBoundItem as Teacher;
            Dal4Teachers.DeleteTeacher(tcherSelected);
            MessageBox.Show(string.Format("删除老师{0}成功", tcherSelected.Name));

            ///【闻祖东 2013-2-17-234608】你本质上是需要再执行一下“查询”按钮下面所需要做的事情
            btnSearch.PerformClick();
        }
    }
}
